#include "addruledialog.h"
#include "ui_addruledialog.h"

addRuleDialog::addRuleDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::addRuleDialog)
{
    ui->setupUi(this);
}

addRuleDialog::~addRuleDialog()
{
    delete ui;
}

void addRuleDialog::changeEvent(QEvent *e)
{
    QDialog::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

QString addRuleDialog::getRule()
{
    return ui->lineEdit->text();
}

void addRuleDialog::setRule( QString rule )
{
    ui->lineEdit->setText( rule );
}

void addRuleDialog::on_buttonBox_accepted()
{
    if ( ui->lineEdit->text().isEmpty() )
        QMessageBox::critical( this, "Add rule", "You must specify rule" );
    else
        accept();
}

void addRuleDialog::on_buttonBox_rejected()
{
    reject();
}
